<template>
  <div>
    <el-table
        :data="data.filter(data => !search || data.username.toLowerCase().includes(search.toLowerCase()))"
        stripe
        max-height="450"
        :default-sort = "{prop: 'date', order: 'descending'}"
        border
        style="width: 100%">
      <el-table-column
          width="110"
          fixed
          sortable
          label="申请日期"
          prop="created">
      </el-table-column>
      <el-table-column
          fixed
          label="店铺名称"
          width="110"
          prop="shopName">
      </el-table-column>
      <el-table-column
          width="110"
          label="所属用户"
          prop="username">
      </el-table-column>
      <el-table-column
          width="110"
          label="联系电话"
          prop="telephone">
      </el-table-column>
      <el-table-column
          width="200"
          label="银行账户"
          prop="bankAccount">
      </el-table-column>
      <el-table-column
          width="80"
          label="身份证">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <img :src="scope.row.picId" class="pic">
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">查看</el-tag>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
          width="80"
          label="营业执照">
        <template slot-scope="scope">
          <el-popover trigger="hover" placement="top">
            <img :src="scope.row.picShop" class="pic">
            <div slot="reference" class="name-wrapper">
              <el-tag size="medium">查看</el-tag>
            </div>
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column
          fixed="right"
          label="操作">
        <template slot-scope="scope">
          <el-button
              v-if="!isAll"
              size="mini"
              type="danger"
              @click="changeRequest(scope.row)">通过</el-button>
          <el-button
              v-if="isAll"
              size="mini"
              type="danger"
              @click="changeRequest(scope.row)">禁用</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: "businessTable",
  props: ['data', 'search', 'isAll'],
  data() {
    return {
    }
  },
  methods: {
    changeRequest(val){
      this.$bus.$emit('changeBusinessPass', val)
    },
  },
}
</script>

<style scoped>
.pic{
  width: 200px;
  height: 200px;
}
</style>